package org.brownflat.lighthouse.ci.hudson;

import org.brownflat.lighthouse.ci.ConnectionException;
import org.brownflat.lighthouse.ci.HTTPServer;
import org.brownflat.lighthouse.ci.Monitorable;

public class HudsonServer extends HTTPServer implements Monitorable {

	public HudsonServer(String host, int port) {
		super(host, port);		
	}
	
	@Override
	public boolean hasAnyBrokenBuilds() {
		HudsonLatestBuildsRequest request = new HudsonLatestBuildsRequest();
		String response = null;
		try {
			response = execute(request);
		} catch (ConnectionException e) {
			throw new RuntimeException(e);
		}
		return response.contains("FAILURE") || response.contains("UNSTABLE");
	}
}
